package com.hurl.waguji.base;

import java.io.InputStream;

public class ConfigHelper {
	public static InputStream getResourceAsStream(String resource) {
		String stripped = resource.startsWith("/") ? resource.substring(1) : resource;

		InputStream stream = null;
		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
		if (classLoader != null) {
			stream = classLoader.getResourceAsStream(stripped);
		}
		
		if(stream==null){
			stream = ConfigHelper.class.getResourceAsStream(resource);
		}
		if(stream==null){
			throw new WagujiRuntimeException("资源文件"+resource+"不存在，请检查配置！");
		}
		return stream;
	}
}
